function [ listLP, listCharacter, lsPlateColor, lsCharSeg ] = MainModeRunDemo( ...
    Io, IS_DEBUG, file_name, conSauvola, conFilter1, conFilter2 )
%MAINMODERUNDEMO Summary of this function goes here
%   Detailed explanation goes here
tic;
FOLDER_RESULT = '.';
[pathstr, name, ext] = fileparts(file_name);
ext = '.JPG';


% Io = imresize(Io,[1600 NaN]);

%% Thuc hien Sauvola
Isau = Sauvola(Io, conSauvola);

%% Thuc hien edge detection
Iedgedetect = EdgeDetect(Io);

%
%% And image with edge detect and sauvola
I3 = EdgeAndSauvola(Iedgedetect, Isau);


%% Thuc hien measureFilter
result={};
resultF={};
arrayResultPosition = {};
[ arrayResultBinary, arrayResultOrg, arrayResultPosition, color_binary, IedgeEdit] = MeasureFilter(I3,  Iedgedetect, Io, false, ...
    IS_DEBUG, conFilter1, FOLDER_RESULT, name ,result, resultF, arrayResultPosition );  % mang chua cac anh thoa dieu kien duoc chon ra


%% Tien hanh loc lai lan thu 2 cho nung truong hop bi nhieu o vien xe
IedgeEdit = imdilate(IedgeEdit,strel('square',2));
% IedgeEdit = imdilate(IedgeEdit,strel('disk',2));
I3Edit = EdgeAndSauvola(IedgeEdit, Isau);
[ arrayResultBinary, arrayResultOrg, arrayResultPosition, color_binary, IedgeEdit] = MeasureFilter(I3Edit,  IedgeEdit, Io, false, ...
    IS_DEBUG, conFilter1,FOLDER_RESULT, name ,arrayResultBinary, arrayResultOrg, arrayResultPosition );


%% tien hanh hien thi cac anh phan loai duoc

[arrImageRe ,arrayImageResultColor, arrayImagResPosition,  a] = DisplayImage(arrayResultBinary, arrayResultOrg, arrayResultPosition, IS_DEBUG,  conFilter2, name, FOLDER_RESULT);

%% nhan dang cac ky tu trong bien so
[finalArrPlate, finalArrPlateColor,  finalArrCharacter, finalArrayPosition, finalArrayCharSeg] = characterSegment.StepRecognizeCharacter(arrImageRe, arrayImageResultColor, arrayImagResPosition, FOLDER_RESULT, IS_DEBUG,file_name);

% listLP = arrayImageResultColor;
% listCharacter = {};
% lsPlateColor = {};
%
% [finalArrPlate, finalArrPlateColor,  finalArrCharacter] = StepRecognizeCharacter(arrImageRe, arrayImageResultColor,FOLDER_RESULT, IS_DEBUG,file_name);
listLP = finalArrPlate;
listCharacter = finalArrCharacter;
lsPlateColor = finalArrPlateColor;
lsCharSeg =    finalArrayCharSeg;

toc;

end

